<meta charset="utf-8">
<script type="text/javascript">
var pid="{$profile.id}";
var followReply;
try {
	followReply="{$profile.followReply}";
	if(followReply!=''){
		eval("followReply="+followReply+";");
	}
} catch (e) {
}
var profilevar ={
		id:pid,
		followReply:followReply,
};
$(function(){
	$('.tab li a').click(function(){
		var $li=$(this).parent();
		var $tab=$li.parent();
		var $div=$tab.parent();
		$div.find('.pane').hide();
		$div.find($(this).attr('href')).show();
		$tab.find(".selected").removeClass('selected');
		$li.addClass('selected');
	});
	$(".appmsg").click(function(){
		var $msgs=$(this).parent();
		$msgs.find(".current").removeClass("current");
		$(this).addClass('current');
	});
	initTextarea();
});

function initTextarea() {
	if(profilevar.followReply){
		var value=profilevar.followReply.value;
		var type=profilevar.followReply.type;
		$('#followReplySettingArea li[data-type="'+type+'"] a').click();
		switch (type) {
		case 1:
			$("#followReply").val(value);
			break;
		case 2:
			$('#added_reply_tuwen div[id="'+value+'"]').addClass('current');
			break;
		default:
			break;
		}
	}
	setWordsLimit($("textarea").first());
}

/**
 * 保存关注回复内容
 */
function saveFollowReply(){
	var $div=$('#followReplySettingArea');
	var type=$div.find('.selected').data('type');
	var value="";
	switch (type) {
	case 1:
		value=$('#followReply').val();
		break;
	case 2:
		value=$div.find('.current').attr('id');
		break;
	default:
		break;
	}
	if(type==2 && !value){
		alert('选择要回复的消息');
		return ;
	}
	var json="{type:"+type+",value:'"+value+"'}";
	$.ajax({
		url:"{:U('Reply/updateFollowReply')}",
		type:"post",
		dataType:"json",
		data:{attrValue:json},
		success:function(data){
			if(data.success){
				showMessage('修改成功！');
			}else{
				showMessage('保存成功！');
			}
		}
	});
}
</script>
<div class="container-fluid">
	<ol class="breadcrumb" style="margin-bottom: 0px">
		<li>
			<a href="{:U('Manage/index')}">首页</a>
		</li>
	
		<li>
			消息回复
		</li>
	</ol>
	<div>
		<div class='panel   col-md-12'>
			<div class="content smartpage">
				<div class="page-header">
					<h1>
						被添加自动回复 <small>当用户第一次关注时，回复以下消息</small>
					</h1>
				</div>
				
				<div id="followReplySettingArea" class="settingArea">
					<div class="c-gA cLine" style="position: relative;">
						<div class="noEditLayer" id='noEditSign'></div>
						<div class="msgSenderPlugin" >
							<ul class="tab">
								<li class=" chooseMedia chooseMedia1" data-type="1">
								<a	href="#added_reply_text">文字</a></li>
								<!-- 		<li class="chooseMedia vioce chooseMedia3" data-type="3">
									语音
								</li>
								<li class="chooseMedia chooseMedia2" data-type="2" >
									图片
								</li>
								<li class="chooseMedia chooseMedia4" data-type="4">
									视频
								</li>-->
								<li class="chooseMedia chooseMedia10" data-type="2">
								<a href="#added_reply_tuwen">图文</a></li>
							</ul>
							<div class='pane' id='added_reply_text' style="display: block;">
								<div class="txtArea">
									<div class="functionBar">
				
										<div class="tip">
											还可以输入 <span class="b i">300</span> 字
										</div>
										<div class="clr"></div>
									</div>
									<div class="editArea">
										<textarea id="followReply" maxLength=300 style="width: 100%;height: 100px"
											onkeyup="setWordsLimit(this)"></textarea>
									</div>
								</div>
				
							</div>
							<div class='pane' id='added_reply_tuwen'>
								<div class="txtArea">
									<div class="functionBar">
										<div class="tip">请选择您要绑定的图文消息</div>
										<div class="clr"></div>
									</div>
								</div>
								<div class="editArea">
								<volist name="graphicList" id="gra" >
										<div class="appmsg " id="{$gra.id}">
											 <volist name="gra['articles']" id="art">
												<if condition="$i eq 0">
													<div class='item'>
														<div class="appmsg_content">
															<h4 class="appmsg_title">{$art.head_title }</h4>
															<div class="appmsg_info">
																<em class="appmsg_date"></em>
															</div>
															<div class="appmsg_thumb_wrp">
																<img  src="{:U('File/downLoad')}/id/{$art.img_id}"
																	style="width: 310px;height: 160px" class="appmsg_thumb">
															</div>
															<p class="appmsg_desc">{$art.summary}</p>
														</div>
				
													</div>
												<else/>
													<div id="appmsgItem2" class="appmsg_item js_appmsg_item "
														data-id="3" data-fileid="">
														<img class="js_appmsg_thumb appmsg_thumb" src="{:U('File/downLoad')}/id/{$art.img_id}">
														<h4 class="appmsg_title">
															<a target="_blank" href="javascript:void(0);"
																onclick="return false;">{$art.head_title}</a>
														</h4>
													</div>
												</if>
											</volist>
											<img src='__PUBLIC__/img/big_sel.png' class='sel'>
										</div>
									</volist>
								</div>
							</div>
						</div>
						<div class="mask"></div>
						<div class="btnArea">
							<input type="button" class=" btn btn-success"
								onclick="saveFollowReply()" value="保 存" />
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>		
</div>